package com.mcc.app.stock.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.mcc.app.stock.domain.SinterMatter;
import com.mcc.app.stock.service.ISinterMatterService;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.core.page.TableDataInfo;
import com.mcc.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 物料配置
 *
 * @author gxy
 * @date 2024-07-30
 */
@Api(tags = "物料配置")
@RestController
@RequestMapping("/stock/sinterMatter")
public class SinterMatterController extends BaseController {

    @Autowired
    private ISinterMatterService sinterMatterService;

    @ApiOperation("查询物料配置列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('stock:sinterMatter:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<SinterMatter>> list(SinterMatter sinterMatter) {
        List<SinterMatter> list = sinterMatterService.selectSinterMatterList(sinterMatter);
        return getDataTable(list);
    }

    @ApiOperation("查询物料配置列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('stock:sinterMatter:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<SinterMatter>> page(SinterMatter sinterMatter) {
        startPage();
        List<SinterMatter> list = sinterMatterService.selectSinterMatterList(sinterMatter);
        return getDataTable(list);
    }

    @ApiOperation("获取物料配置详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('stock:sinterMatter:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<SinterMatter> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sinterMatterService.selectSinterMatterById(id));
    }

    @ApiOperation("新增物料配置")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('stock:sinterMatter:add')")
    @Log(title = "物料配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SinterMatter sinterMatter) {
        return toAjax(sinterMatterService.insertSinterMatter(sinterMatter));
    }

    @ApiOperation("修改物料配置")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('stock:sinterMatter:edit')")
    @Log(title = "物料配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SinterMatter sinterMatter) {
        return toAjax(sinterMatterService.updateSinterMatter(sinterMatter));
    }

    @ApiOperation("删除物料配置")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('stock:sinterMatter:remove')")
    @Log(title = "物料配置", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sinterMatterService.deleteSinterMatterByIds(ids));
    }
}
